package validator

import "regexp"

type noEmptyType struct{}

var noEmptyReg = regexp.MustCompile("^[\\s]+$")

func (t *noEmptyType) Validate(name string, val string, required bool) (bool, string) {
	if val == "" {
		if required {
			return false, name + "不能为空"
		}
		return true, ""
	}

	if noEmptyReg.MatchString(val) {
		return false, name + "不能为空格等字符"
	}

	return true, ""
}
